package com.test.server.utils;

import java.util.regex.Pattern;

import com.test.server.RequestType;

public class Utils {
    
    private static final Pattern XML_PATTERN = Pattern.compile("<.*>", Pattern.MULTILINE|Pattern.DOTALL);
    private static final Pattern JSON_PATTERN = Pattern.compile("\\{.*\\}", Pattern.MULTILINE|Pattern.DOTALL);
    
    public static RequestType getRequestType(String content) {
        if (XML_PATTERN.matcher(content).matches()) {
            return RequestType.XML;
        } else if (JSON_PATTERN.matcher(content).matches()) {
            return RequestType.JSON;
        }
        return RequestType.TEXT;
    }
}
